<template>
    <div>
        <h1 style="text-align: center">施工进度计划</h1>
        <div class="topbox">
            <h3 style="margin-left: 20px">基本信息</h3>
            <el-form :model="build_progress" inline label-position="top" label-width="200px"   >
                <el-form-item label="所属项目:"   class="item">
                    <el-input v-model="build_progress.type_name" @focus="CheckProjectName" ></el-input>
                </el-form-item>
                <el-form-item label="施工主任务"  class="item">
                    <el-input v-model="build_progress.main_task" ></el-input>
                </el-form-item>
                <el-form-item label="施工子任务"  class="item"	>
                    <el-input v-model="build_progress.sub_task"></el-input>
                </el-form-item>
                <el-form-item label="开始日期"  class="item">
                    <el-input v-model="build_progress.start_date"  type="date"></el-input>
                </el-form-item>
                <el-form-item label="结束日期"  class="item">
                    <el-input v-model="build_progress.end_date" type="date"></el-input>
                </el-form-item>
                <el-form-item label="附件" class="item">
                    <el-upload
                            name="multipartfile"
                            action="http://localhost/upload"
                            :headers="{token:this.$store.state.token}"
                            :data="{folder:'build_progress'}"
                            class="upload-demo"
                            ref="upload"
                            :limit="1"
                            :multiple="false"
                            :auto-upload="false"
                            :on-success="handleUploadSuccess">
                        <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                        <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button>
                    </el-upload>
                </el-form-item >

            </el-form>
            <el-dialog :visible.sync="projectTableVisible">
                <project-info-list v-on:row="row" v-if="projectTableVisible"></project-info-list>
            </el-dialog>
        </div>
        <div style="margin-left: 50px;margin-top: 20px">
            <el-button @click="com">提交</el-button>
        </div>
    </div>
</template>

<script>
    import ProjectInfoList from '../common/projectInfo/ProjectInfoList.vue';
    import {BuildProgressService} from '../../model/ww/BuildProgressService.js'
    const buildProgressService=BuildProgressService.getInstance()

    export default {
        name: "Construction",
        data(){
            return {
                build_progress:{
                },
                projectTableVisible:false
            }
        },
        methods:{
            com(){
                buildProgressService.save(this.build_progress).then(()=>{

                })
            }
            ,
            CheckProjectName(){
                this.projectTableVisible = true;
            },
            row(row){
                this.projectTableVisible=false
                this.build_progress.type_name=row.projectName
                this.build_progress.p_id=row.id

            },
            handleUploadSuccess(){

            },
            submitUpload(){
                this.$refs.upload.submit();
            }

        },
        components:{
            ProjectInfoList
        }
    }
</script>

<style scoped>
    .item{
        width: 300px;
        margin-left: 50px;
        margin-top: 20px;
    }
</style>